# $Id: PKGBUILD 65447 2012-02-21 05:50:17Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>

pkgname=slmodem-utils
pkgver=2.9.11
_date=20080126
pkgrel=18
pkgdesc="Userspace tools for the Smartlink winmodems"
arch=('i686')
license=('custom')
url="http://linmodems.technion.ac.il/packages/smartlink/"
depends=('bash' 'alsa-lib')
source=("http://linmodems.technion.ac.il/packages/smartlink/slmodem-${pkgver}-${_date}.tar.gz"
        'slmodem.rc.d' 'slmodem-alsa.rc.d' 'slmodem.conf.d' 'slmodem-alsa.conf.d')
options=('!libtool')

build() { 
  cd "${srcdir}"/slmodem-$pkgver-${_date}

  sed -i 's|<modem.h>|"modem.h"|' modem/*.{c,h}
  sed -i 's|<modem_debug.h>|"modem_debug.h"|' modem/*.{c,h}
  sed -i 's|<modem_defs.h>|"modem_defs.h"|' modem/*.{c,h}
  sed -i 's|<modem_homolog.h>|"modem_homolog.h"|' modem/*.{c,h}
  sed -i 's|<modem_dp.h>|"modem_dp.h"|' modem/*.{c,h}
  sed -i 's|<modem_timer.h>|"modem_timer.h"|' modem/*.{c,h}
  sed -i 's|<modem_param.h>|"modem_param.h"|' modem/*.{c,h}

  unset LDFLAGS
  unset CFLAGS
  make SUPPORT_ALSA=1 DESTDIR="${pkgdir}" all

  #Install driver loader
  install -D -m755 modem/slmodemd "${pkgdir}"/usr/sbin/slmodemd
  # Install daemon files
  install -D -m755 "${srcdir}"/slmodem.rc.d "${pkgdir}"/etc/rc.d/slmodem
  install -D -m755 "${srcdir}"/slmodem-alsa.rc.d "${pkgdir}"/etc/rc.d/slmodem-alsa
  install -D -m644 "${srcdir}"/slmodem.conf.d "${pkgdir}"/etc/conf.d/slmodem
  install -D -m644 "${srcdir}"/slmodem-alsa.conf.d "${pkgdir}"/etc/conf.d/slmodem-alsa
  # adding udev symlink for /dev/modem
  install -d "${pkgdir}"/etc/udev/rules.d
  echo 'ACTION=="add", DRIVERS=="slamr", RUN+="/lib/udev/load-modules.sh ppp-generic"' > "${pkgdir}"/etc/udev/rules.d/slmodem.rules
  echo 'KERNEL==slamr[0-9]', MODE="0660", GROUP="tty", SYMLINK+="modem" >> "${pkgdir}"/etc/udev/rules.d/slmodem.rules
  echo 'ACTION=="add", DRIVERS=="slusb", RUN+="/lib/udev/load-modules.sh ppp-generic"' >> "${pkgdir}"/etc/udev/rules.d/slmodem.rules
  echo 'KERNEL==slusb[0-9]', MODE="0660", GROUP="tty", SYMLINK+="modem" >> "${pkgdir}"/etc/udev/rules.d/slmodem.rules
  # install license
  install -D -m644 COPYING "${pkgdir}"/usr/share/licenses/$pkgname/LICENSE
}
md5sums=('8670dd7e1e1a46296ac4c80f7ac0471d'
         '838e1bde2a3e6fed35c075c25ee79da6'
         '1494b0c87d9ccd3615a1708f24d78f8d'
         '31f9d0eafe052a37e83c150146472956'
         '03accf76458cbf8afde07e445e9b72d0')
